import 'package:meiyunapp/entity/near_bystore_entity.dart';

nearBystoreEntityFromJson(NearBystoreEntity data, Map<String, dynamic> json) {
	if (json['pageNo'] != null) {
		data.pageNo = json['pageNo'] is String
				? int.tryParse(json['pageNo'])
				: json['pageNo'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['pageCount'] != null) {
		data.pageCount = json['pageCount'] is String
				? int.tryParse(json['pageCount'])
				: json['pageCount'].toInt();
	}
	if (json['count'] != null) {
		data.count = json['count'] is String
				? int.tryParse(json['count'])
				: json['count'].toInt();
	}
	if (json['startNumber'] != null) {
		data.startNumber = json['startNumber'] is String
				? int.tryParse(json['startNumber'])
				: json['startNumber'].toInt();
	}
	if (json['list'] != null) {
		data.xList = (json['list'] as List).map((v) => NearBystoreList().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> nearBystoreEntityToJson(NearBystoreEntity entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['pageNo'] = entity.pageNo;
	data['pageSize'] = entity.pageSize;
	data['pageCount'] = entity.pageCount;
	data['count'] = entity.count;
	data['startNumber'] = entity.startNumber;
	data['list'] =  entity.xList.map((v) => v.toJson()).toList();
	return data;
}

nearBystoreListFromJson(NearBystoreList data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['distance'] != null) {
		data.distance = json['distance'] is String
				? int.tryParse(json['distance'])
				: json['distance'].toInt();
	}
	if (json['distanceStr'] != null) {
		data.distanceStr = json['distanceStr'].toString();
	}
	if (json['tagIds'] != null) {
		data.tagIds = json['tagIds'];
	}
	if (json['cityId'] != null) {
		data.cityId = json['cityId'] is String
				? int.tryParse(json['cityId'])
				: json['cityId'].toInt();
	}
	if (json['products'] != null) {
		data.products = (json['products'] as List).map((v) => NearBystoreListProducts().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> nearBystoreListToJson(NearBystoreList entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['distance'] = entity.distance;
	data['distanceStr'] = entity.distanceStr;
	data['tagIds'] = entity.tagIds;
	data['cityId'] = entity.cityId;
	data['products'] =  entity.products.map((v) => v.toJson()).toList();
	return data;
}

nearBystoreListProductsFromJson(NearBystoreListProducts data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['coverImage'] != null) {
		data.coverImage = json['coverImage'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['costPrice'] != null) {
		data.costPrice = json['costPrice'] is String
				? num.tryParse(json['costPrice'])
				: json['costPrice'];
	}
	if (json['salesPrice'] != null) {
		data.salesPrice = json['salesPrice'] is String
				? num.tryParse(json['salesPrice'])
				: json['salesPrice'];
	}
	if (json['activePrice'] != null) {
		data.activePrice = json['activePrice'] is String
				? num.tryParse(json['activePrice'])
				: json['activePrice'];
	}
	if (json['stock'] != null) {
		data.stock = json['stock'] is String
				? int.tryParse(json['stock'])
				: json['stock'].toInt();
	}
	if (json['totalSales'] != null) {
		data.totalSales = json['totalSales'] is String
				? num.tryParse(json['totalSales'])
				: json['totalSales'];
	}
	if (json['couponId'] != null) {
		data.couponId = json['couponId'].toString();
	}
	if (json['voucherId'] != null) {
		data.voucherId = json['voucherId'].toString();
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? int.tryParse(json['price'])
				: json['price'].toInt();
	}
	if (json['categoryIds'] != null) {
		data.categoryIds = json['categoryIds'].toString();
	}
	if (json['storeId'] != null) {
		data.storeId = json['storeId'].toString();
	}
	if (json['buyFlag'] != null) {
		data.buyFlag = json['buyFlag'] is String
				? int.tryParse(json['buyFlag'])
				: json['buyFlag'].toInt();
	}
	return data;
}

Map<String, dynamic> nearBystoreListProductsToJson(NearBystoreListProducts entity) {
	final Map<String, dynamic> data = <String, dynamic>{};
	data['id'] = entity.id;
	data['coverImage'] = entity.coverImage;
	data['name'] = entity.name;
	data['costPrice'] = entity.costPrice;
	data['salesPrice'] = entity.salesPrice;
	data['activePrice'] = entity.activePrice;
	data['stock'] = entity.stock;
	data['totalSales'] = entity.totalSales;
	data['couponId'] = entity.couponId;
	data['voucherId'] = entity.voucherId;
	data['price'] = entity.price;
	data['categoryIds'] = entity.categoryIds;
	data['storeId'] = entity.storeId;
	data['buyFlag'] = entity.buyFlag;
	return data;
}